import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * isShow: true               if set true, will always show the root menu
 *                                if not set isShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
		roles: ['admin','editor']    control the page roles (you can set multiple roles)
		title: 'title'               the name show in sidebar and breadcrumb (recommend set)
		icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
		noCache: true                if set true, the page will no be cached(default is false)
		affix: true                  if set true, the tag will affix in the tags-view
		breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
		activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
	}
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [{
      path: '/redirect/:path(.*)',
      component: () => import('@/views/redirect/index')
    }]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      component: () => import('@/views/home/index'),
      meta: {
        title: [{
            langId: 1,
            name: '首页'
          },
          {
            langId: 2,
            name: 'home'
          },
          {
            langId: 3,
            name: 'Главн страниц'
          },
          {
            langId: 4,
            name: 'Bosh sahifa'
          },
          {
            langId: 5,
            name: 'Үй'
          }
        ],
        icon: 'home',
        affix: true
      }
    }]
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/all-hidden-page',
    component: Layout,
    redirect: '/all-hidden-page/personal-center',
    hidden: true,
    children: [{
        path: 'personal-center',
        component: () => import('@/views/personal-center'),
        meta: {
          title: [{
              langId: 1,
              name: '个人中心'
            },
            {
              langId: 2,
              name: 'Personal Center'
            },
            {
              langId: 3,
              name: ' Индивидуальный центр'
            },
            {
              langId: 4,
              name: 'Shaxsiy markaz'
            },
            {
              langId: 5,
              name: 'Жеке орталық'
            }
          ]
        }
      },

      {
        path: '/authorization',
        component: () => import('@/views/pages/system-manager/authorization'),
        meta: {
          title: [{
              langId: 1,
              name: '角色权限设置'
            }, {
              langId: 2,
              name: 'Role permission setting'
            },
            {
              langId: 3,
              name: 'Установка права персонажа'
            },
            {
              langId: 4,
              name: 'Role asoslangan ruxsat moslamalari'
            },
            {
              langId: 5,
              name: 'Рөлге негізделген рұқсат параметрлері'
            }
          ]
        }
      },
      {
        path: '/car-series-info',
        component: () => import('@/views/pages/basic-manager/vehicle-Inventory-manager/car-series-info'),
        meta: {
          title: [{
              langId: 1,
              name: '车系管理'
            },
            {
              langId: 2,
              name: 'Vehicle series management'
            },
            {
              langId: 3,
              name: 'Управление автомобилем'
            },
            {
              langId: 4,
              name: 'Avtomobilni boshqarish'
            },
            {
              langId: 5,
              name: 'Флотты басқару'
            },
          ],
        },
      }, {
        path: '/vehicle-manager-info',
        component: () => import('@/views/pages/basic-manager/vehicle-Inventory-manager/vehicle-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '车型管理'
            },
            {
              langId: 2,
              name: 'Vehicle model management'
            },
            {
              langId: 3,
              name: 'Управление автомобилем'
            },
            {
              langId: 4,
              name: 'Avtomobilni boshqarish'
            },
            {
              langId: 5,
              name: 'Көлік құралдарының моделін басқару'
            },
          ],
        },
      },
      {
        path: '/company-manager-info',
        component: () => import('@/views/pages/organizational-chart/company-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '集团信息'
            },
            {
              langId: 2,
              name: 'Group Information'
            },
            {
              langId: 3,
              name: 'Групповая информация.'
            },
            {
              langId: 4,
              name: 'Guruh haqida maʼlumot'
            },
            {
              langId: 5,
              name: 'Топ ақпараты'
            },
          ],
        }
      },
      {
        path: '/store-manager-info',
        component: () => import('@/views/pages/organizational-chart/store-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '门店信息'
            },
            {
              langId: 2,
              name: 'Store information'
            },
            {
              langId: 3,
              name: 'Информация о магазине.'
            },
            {
              langId: 4,
              name: 'Maʼlumotni saqlash'
            },
            {
              langId: 5,
              name: 'Маалымат сактоо'
            },
          ],
        }
      },
      {
        path: '/staff-manager-info',
        component: () => import('@/views/pages/organizational-chart/staff-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '员工信息'
            },
            {
              langId: 2,
              name: 'Employee Information'
            },
            {
              langId: 3,
              name: 'Информация о персонале.'
            },
            {
              langId: 4,
              name: `Xodimlar haqida ma'lumot`
            },
            {
              langId: 5,
              name: 'Қызметкерлер туралы мәліметтер'
            },
          ],
        }
      },
      {
        path: '/blos-manager-info',
        component: () => import('@/views/pages/app-set/navigation-manager/blos-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '常用功能'
            },
            {
              langId: 2,
              name: 'Common functions'
            },
            {
              langId: 3,
              name: 'Функция общего пользования'
            },
            {
              langId: 4,
              name: `Keng qo'llaniladigan funksiyalar`
            },
            {
              langId: 5,
              name: 'Жиі қолданылатын функциялар'
            },
          ],
        }
      },
      {
        path: '/approve-manager-info',
        component: () => import('@/views/pages/basic-manager/approval-manager/approve-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '审批管理信息'
            },
            {
              langId: 2,
              name: 'Approval information'
            },
            {
              langId: 3,
              name: 'Одобренная информация.'
            },
            {
              langId: 4,
              name: `Tasdiqlash haqida ma'lumot`
            },
            {
              langId: 5,
              name: 'Бекіту туралы мәліметтер'
            },
          ],
        }
      },
      {
        path: '/supplier-info',
        component: () => import('@/views/pages/basic-manager/supplier-info'),
        meta: {
          title: [{
              langId: 1,
              name: '供应商信息'
            },
            {
              langId: 2,
              name: 'Supplier Information'
            },
            {
              langId: 3,
              name: 'Информация от поставщика'
            },
            {
              langId: 4,
              name: `Yetkazib beruvchi haqida ma'lumot`
            },
            {
              langId: 5,
              name: 'Өнім беруші туралы мәліметтер'
            },
          ],
        }
      },
      {
        path: '/potential-customer-info',
        component: () => import('@/views/pages/client/potential-customer-info'),
        meta: {
          title: [{
              langId: 1,
              name: '潜客管理信息'
            },
            {
              langId: 2,
              name: 'Potential customer management information'
            },
            {
              langId: 3,
              name: 'Данные о противнике'
            },
            {
              langId: 4,
              name: `Istiqbolni boshqarish haqida ma'lumot`
            },
            {
              langId: 5,
              name: 'Перспективаны басқару ақпараты'
            },
          ],
        }
      },
      {
        path: '/direct-putAway-info',
        component: () => import('@/views/pages/commercial-vehicle-manager/direct-putAway-info'),
        meta: {
          title: [{
              langId: 1,
              name: '直接入库详情'
            },
            {
              langId: 2,
              name: 'Direct storage details'
            },
            {
              langId: 3,
              name: 'Сразу в библиотеку'
            },
            {
              langId: 4,
              name: `To'g'ridan-to'g'ri kiruvchi tafsilotlar`
            },
            {
              langId: 5,
              name: 'Тікелей кіру мәліметтері'
            },
          ],
        }
      },
      {
        path: '/repertory-manager-info',
        component: () => import('@/views/pages/commercial-vehicle-manager/repertory-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '库存信息'
            },
            {
              langId: 2,
              name: 'Inventory information'
            },
            {
              langId: 3,
              name: 'Инвентарная информация'
            },
            {
              langId: 4,
              name: `Inventarizatsiya ma'lumotlari`
            },
            {
              langId: 5,
              name: 'Түгендеу мәліметтері'
            },
          ],
        }
      },
      {
        path: '/thread-manager-info',
        component: () => import('@/views/pages/client/thread-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '线索管理信息'
            },
            {
              langId: 2,
              name: 'Lead management information'
            },
            {
              langId: 3,
              name: 'Информация управления зацепками'
            },
            {
              langId: 4,
              name: `Qo'rg'oshin boshqaruvi`
            },
            {
              langId: 5,
              name: 'Қорғасынды басқару'
            },
          ],
        }
      },
      {
        path: '/protocol-manager-info',
        component: () => import('@/views/pages/basic-manager/protocol-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '协议管理信息'
            },
            {
              langId: 2,
              name: 'Protocol management'
            },
            {
              langId: 3,
              name: 'Управление протоколом'
            },
            {
              langId: 4,
              name: `Protokol boshqaruvi`
            },
            {
              langId: 5,
              name: 'Хаттаманы басқару'
            },
          ],
        }
      },

      {
        path: '/quotation-manager-info',
        component: () => import('@/views/pages/commercial-vehicle-sales/quotation-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '报价单详情'
            },
            {
              langId: 2,
              name: 'Quotation details'
            },
            {
              langId: 3,
              name: 'Подробности предложения'
            },
            {
              langId: 4,
              name: `Tafsilotlarni keltiring`
            },
            {
              langId: 5,
              name: 'Дәйексөз мәліметтері'
            },
          ],
        }
      },
      {
        path: '/drive-agreement-info',
        component: () => import('@/views/pages/commercial-vehicle-sales/drive-agreement-info'),
        meta: {
          title: [{
              langId: 1,
              name: '试驾协议详情'
            },
            {
              langId: 2,
              name: 'Test drive agreement'
            },
            {
              langId: 3,
              name: 'Соглашение на тест-драйв.'
            },
            {
              langId: 4,
              name: `Sinov drayveri shartnomasi`
            },
            {
              langId: 5,
              name: 'Сынақ жетегі туралы келісім'
            },
          ],
        }
      },
      {
        path: '/order-agreement-info',
        component: () => import('@/views/pages/commercial-vehicle-sales/order-agreement-info'),
        meta: {
          title: [{
              langId: 1,
              name: '订车协议详情'
            },
            {
              langId: 2,
              name: 'Car booking agreement'
            },
            {
              langId: 3,
              name: 'Договор о бронировании.'
            },
            {
              langId: 4,
              name: `Rezervasyon shartnomalari`
            },
            {
              langId: 5,
              name: 'Брондау туралы келісімдер'
            },
          ],
        }
      },
      {
        path: '/delivery-agreement-info',
        component: () => import('@/views/pages/commercial-vehicle-sales/delivery-agreement-info'),
        meta: {
          title: [{
              langId: 1,
              name: '交车详情'
            },
            {
              langId: 2,
              name: 'Delivery details'
            },
            {
              langId: 3,
              name: 'Подробности по машине'
            },
            {
              langId: 4,
              name: `Etkazib berish tafsilotlari`
            },
            {
              langId: 5,
              name: 'Жеткізу мәліметтері'
            },
          ],
        }
      },

      {
        path: '/sales-delivery-record-info',
        component: () => import('@/views/pages/commercial-vehicle-sales/sales-delivery-record-info'),
        meta: {
          title: [{
              langId: 1,
              name: '销售出库记录详情'
            },
            {
              langId: 2,
              name: 'Sales record details'
            },
            {
              langId: 3,
              name: 'Данные о продажах и вкладах'
            },
            {
              langId: 4,
              name: `Sotuvlar chiqish rekordi tafsilotlari`
            },
            {
              langId: 5,
              name: 'Сатылымның шығыс жазба мәліметтері'
            },
          ],
        }
      },
      {
        path: '/Insurance-billing-record-info',
        component: () => import('@/views/pages/commercial-vehicle-sales/Insurance-billing-record-info'),
        meta: {
          title: [{
              langId: 1,
              name: '保险开单记录'
            },
            {
              langId: 2,
              name: 'Insurance billing records'
            },
            {
              langId: 3,
              name: 'Выписка по страховке'
            },
            {
              langId: 4,
              name: `Sug'urta billing yozuvlari`
            },
            {
              langId: 5,
              name: 'Сақтандыру шотының жазбалары'
            },
          ],
        }
      },
      {
        path: '/store-configure-manager',
        component: () => import('@/views/pages/organizational-chart/store-configure-manager'),
        meta: {
          title: [{
              langId: 1,
              name: '门店配置'
            },
            {
              langId: 2,
              name: 'Store configuration'
            },
            {
              langId: 3,
              name: 'Конфигурация магазина'
            },
            {
              langId: 4,
              name: `Moslamalarni saqlash`
            },
            {
              langId: 5,
              name: 'Сақтау конфигурациясы'
            },
          ],
        }
      },
      {
        path: '/model-sale-info',
        component: () => import('@/views/pages/commercial-vehicle-manager/model-sale-info'),
        meta: {
          title: [{
              langId: 1,
              name: '在售车型'
            }, {
              langId: 2,
              name: 'Model for sale' //英语
            },
            {
              langId: 3,
              name: 'На продаже модели' //俄语
            },
            {
              langId: 4,
              name: 'Sotuvdagi modellar' //乌语
            },
            {
              langId: 5,
              name: 'Сатылымдағы модельдер' //哈萨
            }
          ]
        }
      },
      {
        path: '/parts-manager-info',
        component: () => import('@/views/pages/parts-manager/parts-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '配件详情'
            }, {
              langId: 2,
              name: 'Accessory details' //英语
            },
            {
              langId: 3,
              name: 'Детали аксессуаров' //俄语
            },
            {
              langId: 4,
              name: 'Aksessuarlar Tafsilotlar' //乌语
            },
            {
              langId: 5,
              name: 'Аксессуарлар туралы мәліметтер' //哈萨
            }
          ]
        }
      },
      {
        path: '/purchase-manager-info',
        component: () => import('@/views/pages/parts-manager/purchase-manager-info'),
        meta: {
          title: [{
              langId: 1,
              name: '采购详情'
            }, {
              langId: 2,
              name: 'Purchase details' //英语
            },
            {
              langId: 3,
              name: 'Подробности закупок' //俄语
            },
            {
              langId: 4,
              name: 'Xarid qilish tafsilotlari' //乌语
            },
            {
              langId: 5,
              name: 'Сатып алу туралы мәліметтер' //哈萨
            }
          ]
        }
      },
      {
        path: '/direct-storage-info',
        component: () => import('@/views/pages/parts-manager/direct-storage-info'),
        meta: {
          title: [{
              langId: 1,
              name: '直接入库详情'
            }, {
              langId: 2,
              name: 'Direct storage details' //英语
            },
            {
              langId: 3,
              name: 'Сразу в библиотеку' //俄语
            },
            {
              langId: 4,
              name: `To'g'ridan-to'g'ri kiruvchi tafsilotlar` //乌语
            },
            {
              langId: 5,
              name: 'Тікелей кіру мәліметтері' //哈萨
            }
          ]
        }
      },
      {
        path: '/purchase-warehousing-info',
        component: () => import('@/views/pages/parts-manager/purchase-warehousing-info'),
        meta: {
          title: [{
              langId: 1,
              name: '采购入库详情'
            }, {
              langId: 2,
              name: 'Purchase storage details' //英语
            },
            {
              langId: 3,
              name: 'Подробности о закупках' //俄语
            },
            {
              langId: 4,
              name: `Omborxona detallarini xarid qilish` //乌语
            },
            {
              langId: 5,
              name: 'Қоймалық бөлшектерді сатып алу' //哈萨
            }
          ]
        }
      },
      {
        path: '/modify-price-info',
        component: () => import('@/views/pages/parts-manager/modify-price-info'),
        meta: {
          title: [{
              langId: 1,
              name: '统一调价详情'
            }, {
              langId: 2,
              name: 'Unified price adjustment details' //英语
            },
            {
              langId: 3,
              name: 'Подробности единой цены' //俄语
            },
            {
              langId: 4,
              name: `Birlashgan narxlarni sozlash tafsilotlari` //乌语
            },
            {
              langId: 5,
              name: 'Бағаларды түзетудің бірыңғай деректемелері' //哈萨
            }
          ]
        }
      },
      {
        path: '/purchase-return-info',
        component: () => import('@/views/pages/parts-manager/purchase-return-info'),
        meta: {
          title: [{
              langId: 1,
              name: '采购退货详情'
            }, {
              langId: 2,
              name: 'Purchase return Details' //英语
            },
            {
              langId: 3,
              name: 'Подробности о выкупе' //俄语
            },
            {
              langId: 4,
              name: `Qaytarib berish tafsilotlarini sotib oling` //乌语
            },
            {
              langId: 5,
              name: 'Сатып алудың қайтарым мәліметтері' //哈萨
            }
          ]
        }
      },
      {
        path: '/stock-count-info',
        component: () => import('@/views/pages/parts-manager/stock-count-info'),
        meta: {
          title: [{
              langId: 1,
              name: '库存盘点详情'
            }, {
              langId: 2,
              name: 'Purchase return Details' //英语
            },
            {
              langId: 3,
              name: 'Подробности о выкупе' //俄语
            },
            {
              langId: 4,
              name: `Qaytarib berish tafsilotlarini sotib oling` //乌语
            },
            {
              langId: 5,
              name: 'Сатып алудың қайтарым мәліметтері' //哈萨
            }
          ]
        }
      },
      {
        path: '/maintenanceOut-storage-info',
        component: () => import('@/views/pages/parts-manager/maintenanceOut-storage-info'),
        meta: {
          title: [{
              langId: 1,
              name: '维修出库详情'
            }, {
              langId: 2,
              name: 'Maintenance out of storage details' //英语
            },
            {
              langId: 3,
              name: 'Подробности по техническому обслуживанию' //俄语
            },
            {
              langId: 4,
              name: `Chiqish ma'lumotlarini ta'mirlash` //乌语
            },
            {
              langId: 5,
              name: 'Шығыс бөлшектерін жөндеу' //哈萨
            }
          ]
        }
      },
      {
        path: '/repair-return-info',
        component: () => import('@/views/pages/parts-manager/repair-return-info'),
        meta: {
          title: [{
              langId: 1,
              name: '维修退货详情'
            }, {
              langId: 2,
              name: 'Repair return details' //英语
            },
            {
              langId: 3,
              name: 'Подробности возврата на техобслуживание' //俄语
            },
            {
              langId: 4,
              name: `Qaytish tafsilotlarini ta'mirlash` //乌语
            },
            {
              langId: 5,
              name: 'Жөндеу қайтару мәліметтері' //哈萨
            }
          ]
        }
      },
      {
        path: '/sales-out-stock-info',
        component: () => import('@/views/pages/parts-manager/sales-out-stock-info'),
        meta: {
          title: [{
              langId: 1,
              name: '销售出库详情'
            }, {
              langId: 2,
              name: 'Sales outbound details' //英语
            },
            {
              langId: 3,
              name: 'Подробности продаж в библиотеке' //俄语
            },
            {
              langId: 4,
              name: `Sotuvlar chiqish tafsilotlari` //乌语
            },
            {
              langId: 5,
              name: 'Сатылымның шығыс мәліметтері' //哈萨
            }
          ]
        }
      },
    ]
  },

]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
// const async_Routes = [

// ]

export const exampleRoutes = [{
  path: '/dashboard',
  component: Layout,
  meta: {
    title: [{
      langId: 1,
      name: '开发者管理'
    }, {
      langId: 2,
      name: 'Developer Management'
    }, {
      langId: 3,
      name: ' Управление разработчиками'
    }, {
      langId: 4,
      name: 'Dasturchilarni boshqarish'
    }],
    icon: 'password'
  },
  children: [{
      path: 'menu-manager',
      component: () => import('@/views/dashboard/menu-manager'),
      meta: {
        title: [{
            langId: 1,
            name: '菜单管理菜'
          }, {
            langId: 2,
            name: 'menu management'
          },
          {
            langId: 3,
            name: ' Меню Управление'
          },
          {
            langId: 4,
            name: 'Menyu boshqaruvi'
          }
        ]
      }
    },
    {
      path: 'table_header_manage',
      component: () => import('@/views/dashboard/table_header_manage'),
      meta: {
        title: [{
            langId: 1,
            name: '表头管理'
          }, {
            langId: 2,
            name: 'menu management'
          },
          {
            langId: 3,
            name: ' Меню Управление'
          },
          {
            langId: 4,
            name: 'Menyu boshqaruvi'
          }
        ]
      }
    },

  ]
}, ]

// export const asyncRoutes = async_Routes;

// process.env.NODE_ENV
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export const loadView = (view) => {
  return (resolve) => require([`@/views/${view}.vue`], resolve)
}

export default router
